package com.zerocarbon.framework.cors;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @类名: MyWebConfigurer
 * @描述:
 * @作者: liudf
 * @日期: 2021/6/27 16:47
 */
@Configuration
public class MyWebConfigurer extends WebMvcConfigurerAdapter {

    /**
     * URL patterns which should be excluded
     */
    private static final String[] EXCLUDE_PATTERNS = new String[] {};

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(authWebInterceptor).addPathPatterns("/open/**").excludePathPatterns("/open/picture/**");
        super.addInterceptors(registry);
    }

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedMethods("*").allowedHeaders("*")
                .allowedOriginPatterns("*")
                .allowCredentials(true);
    }

}
